/*
 * caller.c
 *
 *  Created on: 2021年11月18日
 *      Author: 朱国印
 */
#include <string.h>
#include <stdio.h>

int myadd(int a, int b, int *res);
void mywrite(int, char *, int);

int main()
{
	char buf[1024];
	int a, b, res;
	char *mystr = "Calculate...\n";
	char *emsg = "Error in adding\n";

	a = 5; b = 10;
//	a = 123456789; b = 123456789; // 此语句打开，将会溢出，打印Error in adding
	mywrite(1, mystr, strlen(mystr));
	if (myadd(a, b, &res))
	{
		sprintf(buf, "The result is %d\n", res);
		mywrite(1, buf, strlen(buf));
	} else {
		mywrite(1, emsg, strlen(emsg));
	}
	return 0;
}
